package com.wdh.kjs.model;

import java.util.ArrayList;

/**
 * Created by 锋情 on 2014/4/20.
 * changed by loser on 2016/2/25
 */
public class Filters {
    private String groupOp;
    private ArrayList<FilterRule> rules;
    private ArrayList<Filters> groups;

    public Filters() {
        groupOp = "AND";
    }

    public Filters(String groupOp, ArrayList<FilterRule> rules) {
        this.groupOp = groupOp;
        this.rules = rules;
    }

    public Filters(String groupOp, ArrayList<FilterRule> rules, ArrayList<Filters> groups) {
        this.groupOp = groupOp;
        this.rules = rules;
        this.groups = groups;
    }

    public String getGroupOp() {
        return groupOp;
    }

    public void setGroupOp(String groupOp) {
        this.groupOp = groupOp;
    }

    public ArrayList<FilterRule> getRules() {
        return rules;
    }

    public void setRules(ArrayList<FilterRule> rules) {
        this.rules = rules;
    }

    public ArrayList<Filters> getGroups() {
        return groups;
    }

    public void setGroups(ArrayList<Filters> groups) {
        this.groups = groups;
    }

    public void addRules(FilterRule filterRule){
        if(rules == null){
            rules = new ArrayList<>();
        }
        this.rules.add(filterRule);
    }

    public void addGroups(Filters filters){
        if(groups == null){
            groups = new ArrayList<>();
        }
        this.groups.add(filters);
    }

    @Override
    public String toString(){

        return "Filter{" +
                "groupOp='" + groupOp + '\'' +
                ", rules='" + rules + '\'' +
                ", groups='" + groups + '\'' +
                '}';
    }

}
